package cagt.tools.standard;

import cagt.tools.Card;

/**
 * Card of the standard deck.
 * 
 * @author Konrad Sza�kowski
 * 
 */
public class StandardCard extends Card {

	private Color color;
	private Figure figure;

	/**
	 * Constructor initializing the card with color and its figure.
	 * 
	 * @param color
	 *            Color.
	 * @param figure
	 *            Figure.
	 */
	public StandardCard(final Color color, final Figure figure, final int custom) {
		if (color == null || figure == null) {
			throw new NullPointerException();
		}
		this.color = color;
		this.figure = figure;
		// Set the id.
		setId(custom * 1000 + this.color.ordinal() * 100
				+ this.figure.ordinal());
	}

	public StandardCard(final Color color, final Figure figure) {
		this(color, figure, 0);
	}

	/**
	 * Color.
	 * 
	 * @return Color.
	 */
	public Color getColor() {
		return color;
	}

	/**
	 * Figure.
	 * 
	 * @return Figure.
	 */
	public Figure getFigure() {
		return figure;
	}

	@Override
	public boolean equals(Object object) {
		return object instanceof StandardCard
				&& getId() == ((StandardCard) object).getId()
				&& color.equals(((StandardCard) object).color)
				&& figure.equals(((StandardCard) object).figure);
	}

	@Override
	public String toString() {
		return figure + " of " + color + " (" + getId() + ")";
	}
}
